package com.gome.han.bigdata.spark.core.rdd.operation.transformation

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author Hanpeng
 * @date 2021/1/12 22:21
 * @description: 将分区中的所有元素合并到一个数组中 本例子中有两个数组
 */
object GlomOperation {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Operator")
    val sc = new SparkContext(sparkConf)

    // TODO 算子 - glom
    val rdd : RDD[Int] = sc.makeRDD(List(1,2,3,4), 2)

    // List => Int
    // Int => Array
    val glomRDD: RDD[Array[Int]] = rdd.glom()

    glomRDD.collect().foreach(data=> println(data.mkString(",")))





    sc.stop()

  }
}
